﻿using NHibernate;

namespace ParaEditor.Common.NHibernate
{
    public class NHibernateMember
    {
        private ISession _session;
        private ISession _sessionSource;

        private NHibernateHelper _helper;

        private static NHibernateMember instance;
        //做导入时用到的数据源
        private static NHibernateMember instanceSource;

        private NHibernateMember()
        { }

        public static NHibernateMember GetInstance()
        {
            if (instance == null)
            {
                instance = new NHibernateMember();
            }
            return instance;
        }

        public static NHibernateMember GetInstanceSource()
        {
            if (instanceSource == null)
            {
                instanceSource = new NHibernateMember();
            }
            return instanceSource;
        }

        public ISession GetSession()
        {
            if (_session != null)
            {
                
            }
            else
            {
                _helper = new NHibernateHelper();
                _session = _helper.GetSession();
            }
            
            return _session;
        }

        public ISession GetSessionSource()
        {
            if (_sessionSource == null)
            {
                _helper = new NHibernateHelper();
                _sessionSource = _helper.GetSessionSource();
            }
            return _sessionSource;
        }
    }
}
